package cn.stylefeng.guns.modular.gridsystem.temperature.controller;

import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import cn.stylefeng.guns.modular.gridsystem.temperature.model.param.BizTemperatureExceptionLogParam;
import cn.stylefeng.guns.modular.gridsystem.temperature.model.param.BizTemperatureExceptionParam;
import cn.stylefeng.guns.modular.gridsystem.temperature.service.BizTemperatureExceptionLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class BizTemperatureExceptionLogController {


    @Autowired
    private BizTemperatureExceptionLogService bizTemperatureExceptionLogService;


    /**
     * 分页查询
     *
     * @param param
     * @return
     */
    @GetMapping("/temperature/errorLog/page")
    @BusinessLog(title = "开关柜温度预警LOG_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(BizTemperatureExceptionLogParam param) {
        return new SuccessResponseData(bizTemperatureExceptionLogService.pageList(param));
    }




    @GetMapping("/temperature/errorLog/del")
    @BusinessLog(title = "温度故障删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData del(BizTemperatureExceptionParam param) {
        if (ObjectUtil.isEmpty(param.getId())) {
            return ResponseData.error("参数不能为空！");
        }
        bizTemperatureExceptionLogService.del(param);
        return new SuccessResponseData();
    }
}
